<%--
  Created by IntelliJ IDEA.
  User: 10332
  Date: 2020/7/24
  Time: 11:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <h1 align="center">部门表</h1>
   <p align="right"><a href="deptSave.jsp">添加</a></p>
    <form method="post" action="deptList" >
        <div align="center" >
            <input type="text" name="dname" value="${dept.dname}" placeholder="部门名称"/>
            <input type="text" name="loc" value="${dept.loc}" placeholder="部门所在地"/>
            <input type="submit" value="查询"/>
        </div>L
    </form>
    <form method="post" action="delDeptSelect">
    <table border="1px" align="center" >
        <tr>
            <th>序号</th>
            <th>部门编号</th>
            <th>部门名称</th>
            <th>部门地址</th>
            <th>编辑</th>
        </tr>
        <c:forEach items="${deptList}" varStatus="status" var="dept">
            <tr>
                <th>${status.count}</th>
                <th>${dept.deptno}</th>
                <th>${dept.dname}</th>
                <th>${dept.loc}</th>
                <th><a href="getOneDept?deptno=${dept.deptno }">修改</a>
                <a href="deleteDept?deptno=${dept.deptno}">删除</a>
                <input type="checkbox" name="deptnos" class="deptnos" value="${dept.deptno}"></th>
            </tr>
        </c:forEach>

        <tr>
            <th colspan="12">
                <button type="button" id="selectAll">全选</button>
                <button type="button" id="selectNone">不选</button>
                <button type="button" id="selectOther">反选</button>
                <button id="delete">删除</button>
            </th>
        </tr>
        <tr>
            <td colspan="12">
                <a href="deptList?pageNum=1">首页</a>
                <a href="deptList?pageNum=${pageInfo.prePage}">上一页</a>
                <a href="deptList?pageNum=${pageInfo.nextPage}">下一页</a>
                <a href="deptList?pageNum=${pageInfo.pages}">尾页</a>
                一共有${pageInfo.pages}页
                一共有${pageInfo.total}条
            </td>
        </tr>
    </table>
    </form>
    <script src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js"></script>
    <script>
        $(document).ready(function(){
            $("#selectAll").click(function(){
                $(".deptnos").prop("checked",true);
            });
            $("#selectNone").click(function(){
                $(".deptnos").prop("checked",false);
            });
            $("#selectOther").click(function(){
                var deptnos = $(".deptnos");
                for(var i=0;i<deptnos.length;i++){
                    deptnos.eq(i).prop("checked",!deptnos.eq(i).prop("checked"));
                }
            });
        });
    </script>
</body>
</html>
